package logic

import (
	"base/models/mysql"
	"context"

	"base/baserpc/baserpc"
	"base/baserpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type LikeLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLikeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LikeLogic {
	return &LikeLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 点赞
func (l *LikeLogic) Like(in *baserpc.LikeRequest) (*baserpc.LikeResponse, error) {
	// todo: add your logic here and delete this line
	var like mysql.Like
	like.NoteId = int(in.NoteId + 1)
	like.UserId = int(in.UserId + 1)
	mysql.DB.Debug().Create(&like)
	return &baserpc.LikeResponse{
		Id: int64(like.ID),
	}, nil
}
